--[[/**
-- * 
 * 免疫buff添加和执行,
 * 触发成功时,添加能量
 *
 * 这个效果类型, 触发时机一定是 36(buff添加前)
-- *
-- */]]

---@class BuffEffect465100 : BaseBuffEffect
BuffEffect465100 = ClientFight.CreateClass("BuffEffect465100", ClientFight.BaseBuffEffect)
local t = BuffEffect465100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local result = parameters[2];
    if (result.damage > 0) then
        --别人已经免疫过了,就不要再免疫了,因为大部分的免疫类 buff 都是触发后移除,
        --所以, 如果有多个这种buff, 如果这里不阻断, 那么, 全都会触发一遍, 白白浪费了 一堆的 免疫buff
        return IBuffEffect.FAIL;
    end
    local addBuff = parameters[1];
    if (addBuff == buff) then
        return IBuffEffect.FAIL;
    end
    local f_buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local type = f_buffEffectValue[2];
    if (addBuff.buffBean.f_BuffType ~= type) then
        return IBuffEffect.FAIL;
    end
    result.damage = result.damage + 1;
    result.state = DamageResultTypeEnum.IMMUNITY;
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local add = buffEffectValue[1];
    FighterManager.addEnergy(fight, buff.target, buff.skill.skill.skillId, fight.frame, add, EnergyChangeReasonEnum.BUFF);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 触发免疫了buff: " .. addBuff.buffBean.f_BuffId .. "  并给自己增加能量: " .. add);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()